<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
	"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
	<meta content="text/html; charset=utf-8" http-equiv="Content-Type" />

	<title>Class: Message</title>

	<link rel="stylesheet" href="./rdoc.css" type="text/css" media="screen" />

	<script src="./js/jquery.js" type="text/javascript"
		charset="utf-8"></script>
	<script src="./js/thickbox-compressed.js" type="text/javascript"
		charset="utf-8"></script>
	<script src="./js/quicksearch.js" type="text/javascript"
		charset="utf-8"></script>
	<script src="./js/darkfish.js" type="text/javascript"
		charset="utf-8"></script>

</head>
<body class="class">

	<div id="metadata">
		<div id="home-metadata">
			<div id="home-section" class="section">
        <h3 class="section-header">
          <a href="./index.html">Home</a>
          <a href="./index.html#classes">Classes</a>
          <a href="./index.html#methods">Methods</a>
        </h3>
			</div>
		</div>

		<div id="file-metadata">
			<div id="file-list-section" class="section">
				<h3 class="section-header">In Files</h3>
				<div class="section-body">
					<ul>
					
						<li><a href="./app/models/message_rb.html?TB_iframe=true&amp;height=550&amp;width=785"
							class="thickbox" title="app/models/message.rb">app/models/message.rb</a></li>
					
					</ul>
				</div>
			</div>

			
		</div>

		<div id="class-metadata">

			<!-- Parent Class -->
			
			<div id="parent-class-section" class="section">
				<h3 class="section-header">Parent</h3>
				
				<p class="link">ActiveRecord::Base</p>
				
			</div>
			

			<!-- Namespace Contents -->
			

			<!-- Method Quickref -->
			
			<div id="method-list-section" class="section">
				<h3 class="section-header">Methods</h3>
				<ul class="link-list">
					
					<li><a href="#method-c-format_types">::format_types</a></li>
					
					<li><a href="#method-i-add_recipient">#add_recipient</a></li>
					
					<li><a href="#method-i-cc_addrs">#cc_addrs</a></li>
					
					<li><a href="#method-i-check_recipient_list">#check_recipient_list</a></li>
					
					<li><a href="#method-i-get_recipient">#get_recipient</a></li>
					
					<li><a href="#method-i-save_attachments">#save_attachments</a></li>
					
					<li><a href="#method-i-set_attr">#set_attr</a></li>
					
					<li><a href="#method-i-set_read_flag">#set_read_flag</a></li>
					
					<li><a href="#method-i-set_recipients">#set_recipients</a></li>
					
					<li><a href="#method-i-set_reply_fields">#set_reply_fields</a></li>
					
					<li><a href="#method-i-to_addrs">#to_addrs</a></li>
					
				</ul>
			</div>
			

			<!-- Included Modules -->
			
		</div>

		<div id="project-metadata">
			
			
			<div id="fileindex-section" class="section project-section">
				<h3 class="section-header">Files</h3>
				<ul>
				
					<li class="file"><a href="./doc/README_FOR_APP.html">README_FOR_APP</a></li>
				
				</ul>
			</div>
			

			<div id="classindex-section" class="section project-section">
				<h3 class="section-header">Class Index
					<span class="search-toggle"><img src="./images/find.png"
						height="16" width="16" alt="[+]"
						title="show/hide quicksearch" /></span></h3>
				<form action="#" method="get" accept-charset="utf-8" class="initially-hidden">
				<fieldset>
					<legend>Quicksearch</legend>
					<input type="text" name="quicksearch" value=""
						class="quicksearch-field" />
				</fieldset>
				</form>

				<ul class="link-list">
				
					<li><a href="./Portal.html">Portal</a></li>
				
					<li><a href="./Portal/FriendsController.html">Portal::FriendsController</a></li>
				
					<li><a href="./Portal/FriendsHelper.html">Portal::FriendsHelper</a></li>
				
					<li><a href="./Portal/MessageAttachmentsController.html">Portal::MessageAttachmentsController</a></li>
				
					<li><a href="./Portal/MessageAttachmentsHelper.html">Portal::MessageAttachmentsHelper</a></li>
				
					<li><a href="./Portal/MessageDestinationsController.html">Portal::MessageDestinationsController</a></li>
				
					<li><a href="./Portal/MessageDestinationsHelper.html">Portal::MessageDestinationsHelper</a></li>
				
					<li><a href="./Portal/MessageFoldersController.html">Portal::MessageFoldersController</a></li>
				
					<li><a href="./Portal/MessageFoldersHelper.html">Portal::MessageFoldersHelper</a></li>
				
					<li><a href="./Portal/MessageOutboxController.html">Portal::MessageOutboxController</a></li>
				
					<li><a href="./Portal/MessageOutboxHelper.html">Portal::MessageOutboxHelper</a></li>
				
					<li><a href="./Portal/MessageRulesController.html">Portal::MessageRulesController</a></li>
				
					<li><a href="./Portal/MessageRulesHelper.html">Portal::MessageRulesHelper</a></li>
				
					<li><a href="./Portal/MessagesController.html">Portal::MessagesController</a></li>
				
					<li><a href="./Portal/MessagesHelper.html">Portal::MessagesHelper</a></li>
				
					<li><a href="./Portal/ProfilesController.html">Portal::ProfilesController</a></li>
				
					<li><a href="./Portal/ProfilesHelper.html">Portal::ProfilesHelper</a></li>
				
					<li><a href="./Portal/TopController.html">Portal::TopController</a></li>
				
					<li><a href="./Portal/TopHelper.html">Portal::TopHelper</a></li>
				
					<li><a href="./Common.html">Common</a></li>
				
					<li><a href="./Common/InvitesController.html">Common::InvitesController</a></li>
				
					<li><a href="./Common/InvitesHelper.html">Common::InvitesHelper</a></li>
				
					<li><a href="./Common/SettingsController.html">Common::SettingsController</a></li>
				
					<li><a href="./Common/SettingsHelper.html">Common::SettingsHelper</a></li>
				
					<li><a href="./Common/UserSessionsController.html">Common::UserSessionsController</a></li>
				
					<li><a href="./Common/UserSessionsHelper.html">Common::UserSessionsHelper</a></li>
				
					<li><a href="./Common/UsersController.html">Common::UsersController</a></li>
				
					<li><a href="./Common/UsersHelper.html">Common::UsersHelper</a></li>
				
					<li><a href="./Admin.html">Admin</a></li>
				
					<li><a href="./Admin/AdminController.html">Admin::AdminController</a></li>
				
					<li><a href="./Admin/GlobalSettingsController.html">Admin::GlobalSettingsController</a></li>
				
					<li><a href="./Admin/GlobalSettingsHelper.html">Admin::GlobalSettingsHelper</a></li>
				
					<li><a href="./Admin/SystemMessagesController.html">Admin::SystemMessagesController</a></li>
				
					<li><a href="./Admin/SystemMessagesHelper.html">Admin::SystemMessagesHelper</a></li>
				
					<li><a href="./Admin/UsersController.html">Admin::UsersController</a></li>
				
					<li><a href="./Admin/UsersHelper.html">Admin::UsersHelper</a></li>
				
					<li><a href="./Mobile.html">Mobile</a></li>
				
					<li><a href="./Mobile/EmoticonHelper.html">Mobile::EmoticonHelper</a></li>
				
					<li><a href="./Mobile/LinkRenderer.html">Mobile::LinkRenderer</a></li>
				
					<li><a href="./ApplicationController.html">ApplicationController</a></li>
				
					<li><a href="./ApplicationHelper.html">ApplicationHelper</a></li>
				
					<li><a href="./AvatarUploader.html">AvatarUploader</a></li>
				
					<li><a href="./BlogAttachmentUploader.html">BlogAttachmentUploader</a></li>
				
					<li><a href="./BoardMessageAttachmentUploader.html">BoardMessageAttachmentUploader</a></li>
				
					<li><a href="./CarrierWaveExtension.html">CarrierWaveExtension</a></li>
				
					<li><a href="./CommonUtils.html">CommonUtils</a></li>
				
					<li><a href="./CommunityAvatarUploader.html">CommunityAvatarUploader</a></li>
				
					<li><a href="./Friend.html">Friend</a></li>
				
					<li><a href="./FriendRequest.html">FriendRequest</a></li>
				
					<li><a href="./GlobalSetting.html">GlobalSetting</a></li>
				
					<li><a href="./Invite.html">Invite</a></li>
				
					<li><a href="./Message.html">Message</a></li>
				
					<li><a href="./MessageAttachment.html">MessageAttachment</a></li>
				
					<li><a href="./MessageAttachmentUploader.html">MessageAttachmentUploader</a></li>
				
					<li><a href="./MessageFolder.html">MessageFolder</a></li>
				
					<li><a href="./MessageRecipient.html">MessageRecipient</a></li>
				
					<li><a href="./MessageRule.html">MessageRule</a></li>
				
					<li><a href="./Profile.html">Profile</a></li>
				
					<li><a href="./Role.html">Role</a></li>
				
					<li><a href="./Setting.html">Setting</a></li>
				
					<li><a href="./SnsMailer.html">SnsMailer</a></li>
				
					<li><a href="./SystemMessage.html">SystemMessage</a></li>
				
					<li><a href="./User.html">User</a></li>
				
					<li><a href="./UserSession.html">UserSession</a></li>
				
				</ul>
				<div id="no-class-search-results" style="display: none;">No matching classes.</div>
			</div>

			
		</div>
	</div>

	<div id="documentation">
		<h1 class="class">Message</h1>

		<div id="description">
			<h3>メッセージ管理用モデル</h3>

		</div>

		<!-- Constants -->
		

		<!-- Attributes -->
		

		<!-- Methods -->
		
		<div id="public-class-method-details" class="method-section section">
			<h3 class="section-header">Public Class Methods</h3>

		
			<div id="format-types-method" class="method-detail ">
				<a name="method-c-format_types"></a>

				<div class="method-heading">
				
					<span class="method-name">format_types</span><span
						class="method-args">()</span>
					<span class="method-click-advice">click to toggle source</span>
				
				</div>

				<div class="method-description">
					
					<h3>メッセージが使用可能なフォーマット形式の一覧を配列で返す</h3>
					

					
					<div class="method-source-code"
						id="format-types-source">
<pre>
    <span class="ruby-comment cmt"># File app/models/message.rb, line 18</span>
18:   <span class="ruby-keyword kw">def</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">format_types</span>
19:     <span class="ruby-keyword kw">return</span> [[<span class="ruby-constant">I18n</span>.<span class="ruby-identifier">t</span>(<span class="ruby-value str">&quot;sns.text_format_strings.plain&quot;</span>),<span class="ruby-value str">&quot;plain&quot;</span>],
20:             [<span class="ruby-constant">I18n</span>.<span class="ruby-identifier">t</span>(<span class="ruby-value str">&quot;sns.text_format_strings.markdown&quot;</span>), <span class="ruby-value str">&quot;markdown&quot;</span>],
21:             [<span class="ruby-constant">I18n</span>.<span class="ruby-identifier">t</span>(<span class="ruby-value str">&quot;sns.text_format_strings.textile&quot;</span>), <span class="ruby-value str">&quot;textile&quot;</span>]]
22:   <span class="ruby-keyword kw">end</span></pre>
					</div>
					
				</div>

				

				
			</div>

		
		</div>
	
		<div id="public-instance-method-details" class="method-section section">
			<h3 class="section-header">Public Instance Methods</h3>

		
			<div id="cc-addrs-method" class="method-detail ">
				<a name="method-i-cc_addrs"></a>

				<div class="method-heading">
				
					<span class="method-name">cc_addrs</span><span
						class="method-args">()</span>
					<span class="method-click-advice">click to toggle source</span>
				
				</div>

				<div class="method-description">
					
					<h3>メッセージに設定されているCc:をカンマ区切りの文字列として取得する</h3>
					

					
					<div class="method-source-code"
						id="cc-addrs-source">
<pre>
    <span class="ruby-comment cmt"># File app/models/message.rb, line 69</span>
69:   <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">cc_addrs</span>
70:     <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">message_recipients</span>.<span class="ruby-identifier">where</span>(<span class="ruby-value">:recipient_type</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-value str">&quot;cc&quot;</span>).<span class="ruby-identifier">collect</span>{<span class="ruby-operator">|</span><span class="ruby-identifier">mr</span><span class="ruby-operator">|</span> <span class="ruby-identifier">mr</span>.<span class="ruby-identifier">user</span>.<span class="ruby-identifier">login</span>}.<span class="ruby-identifier">join</span>(<span class="ruby-value str">&quot;, &quot;</span>)
71:   <span class="ruby-keyword kw">end</span></pre>
					</div>
					
				</div>

				

				
			</div>

		
			<div id="get-recipient-method" class="method-detail ">
				<a name="method-i-get_recipient"></a>

				<div class="method-heading">
				
					<span class="method-name">get_recipient</span><span
						class="method-args">(user)</span>
					<span class="method-click-advice">click to toggle source</span>
				
				</div>

				<div class="method-description">
					
					<p>
引数で指定されたユーザーオブジェクトが宛先（もしくはCc:）に含まれていれば その情報を返す。含まれていなければnilを返す
</p>
					

					
					<div class="method-source-code"
						id="get-recipient-source">
<pre>
    <span class="ruby-comment cmt"># File app/models/message.rb, line 96</span>
96:   <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">get_recipient</span>(<span class="ruby-identifier">user</span>)
97:     <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">message_recipients</span>.<span class="ruby-identifier">where</span>(<span class="ruby-value">:user_id</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">user</span>.<span class="ruby-identifier">id</span>).<span class="ruby-identifier">first</span>
98:   <span class="ruby-keyword kw">end</span></pre>
					</div>
					
				</div>

				

				
			</div>

		
			<div id="save-attachments-method" class="method-detail ">
				<a name="method-i-save_attachments"></a>

				<div class="method-heading">
				
					<span class="method-name">save_attachments</span><span
						class="method-args">(files)</span>
					<span class="method-click-advice">click to toggle source</span>
				
				</div>

				<div class="method-description">
					
					<h3>メッセージに関連付く添付ファイルを保存する</h3>
<p>
保存の実施にはcarrier_waveプラグインが使用されている
</p>
					

					
					<div class="method-source-code"
						id="save-attachments-source">
<pre>
    <span class="ruby-comment cmt"># File app/models/message.rb, line 26</span>
26:   <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">save_attachments</span>(<span class="ruby-identifier">files</span>)
27:     <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">false</span> <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">files</span>
28:     <span class="ruby-identifier">files</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">file</span><span class="ruby-operator">|</span>
29:       <span class="ruby-identifier">attachment</span> = <span class="ruby-constant">MessageAttachment</span>.<span class="ruby-identifier">new</span>
30:       <span class="ruby-identifier">attachment</span>.<span class="ruby-identifier">attachment_file</span> = <span class="ruby-identifier">file</span>
31:       <span class="ruby-identifier">attachment</span>.<span class="ruby-identifier">message</span> = <span class="ruby-keyword kw">self</span>
32:       <span class="ruby-identifier">attachment</span>.<span class="ruby-identifier">filename</span> = <span class="ruby-identifier">file</span>.<span class="ruby-identifier">original_filename</span>
33:       <span class="ruby-identifier">attachment</span>.<span class="ruby-identifier">content_type</span> = <span class="ruby-identifier">file</span>.<span class="ruby-identifier">content_type</span>
34:       <span class="ruby-identifier">attachment</span>.<span class="ruby-identifier">size</span> = <span class="ruby-identifier">file</span>.<span class="ruby-identifier">size</span>
35:       <span class="ruby-identifier">attachment</span>.<span class="ruby-identifier">save</span>
36:     <span class="ruby-keyword kw">end</span>
37:   <span class="ruby-keyword kw">end</span></pre>
					</div>
					
				</div>

				

				
			</div>

		
			<div id="set-attr-method" class="method-detail ">
				<a name="method-i-set_attr"></a>

				<div class="method-heading">
				
					<span class="method-name">set_attr</span><span
						class="method-args">(org_message)</span>
					<span class="method-click-advice">click to toggle source</span>
				
				</div>

				<div class="method-description">
					
					<h3>メッセージの再送時に、前と同じサブジェクトと本文を設定する</h3>
					

					
					<div class="method-source-code"
						id="set-attr-source">
<pre>
     <span class="ruby-comment cmt"># File app/models/message.rb, line 101</span>
101:   <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">set_attr</span>(<span class="ruby-identifier">org_message</span>)
102:     <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">subject</span> = <span class="ruby-identifier">org_message</span>.<span class="ruby-identifier">subject</span>
103:     <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">body</span> = <span class="ruby-identifier">org_message</span>.<span class="ruby-identifier">body</span>
104:     <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">true</span>
105:   <span class="ruby-keyword kw">end</span></pre>
					</div>
					
				</div>

				

				
			</div>

		
			<div id="set-read-flag-method" class="method-detail ">
				<a name="method-i-set_read_flag"></a>

				<div class="method-heading">
				
					<span class="method-name">set_read_flag</span><span
						class="method-args">(user)</span>
					<span class="method-click-advice">click to toggle source</span>
				
				</div>

				<div class="method-description">
					
					<h3>メッセージに既読フラグを立てる</h3>
					

					
					<div class="method-source-code"
						id="set-read-flag-source">
<pre>
    <span class="ruby-comment cmt"># File app/models/message.rb, line 74</span>
74:   <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">set_read_flag</span>(<span class="ruby-identifier">user</span>)
75:     <span class="ruby-identifier">mr</span> = <span class="ruby-identifier">get_recipient</span>(<span class="ruby-identifier">user</span>)
76:     <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">mr</span>.<span class="ruby-identifier">read_flag</span>
77:       <span class="ruby-identifier">mr</span>.<span class="ruby-identifier">read_flag</span> = <span class="ruby-keyword kw">true</span>
78:       <span class="ruby-identifier">mr</span>.<span class="ruby-identifier">save</span>
79:     <span class="ruby-keyword kw">end</span>
80:   <span class="ruby-keyword kw">end</span></pre>
					</div>
					
				</div>

				

				
			</div>

		
			<div id="set-recipients-method" class="method-detail ">
				<a name="method-i-set_recipients"></a>

				<div class="method-heading">
				
					<span class="method-name">set_recipients</span><span
						class="method-args">(to_list, cc_list = "")</span>
					<span class="method-click-advice">click to toggle source</span>
				
				</div>

				<div class="method-description">
					
					<h3>メッセージの受信者情報を設定する</h3>
<p>
実在しないユーザーは登録できないようになっている。
</p>
					

					
					<div class="method-source-code"
						id="set-recipients-source">
<pre>
    <span class="ruby-comment cmt"># File app/models/message.rb, line 41</span>
41:   <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">set_recipients</span>(<span class="ruby-identifier">to_list</span>, <span class="ruby-identifier">cc_list</span> = <span class="ruby-value str">&quot;&quot;</span>)
42:     <span class="ruby-identifier">to_users</span> = <span class="ruby-identifier">check_recipient_list</span>(<span class="ruby-identifier">to_list</span>)
43:     <span class="ruby-identifier">cc_users</span> = <span class="ruby-identifier">check_recipient_list</span>(<span class="ruby-identifier">cc_list</span>)
44: 
45:     <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">false</span> <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">to_users</span>
46:     <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">false</span> <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">cc_users</span>
47: 
48:     <span class="ruby-identifier">to_users</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">user</span><span class="ruby-operator">|</span>
49:       <span class="ruby-identifier">add_recipient</span>(<span class="ruby-identifier">user</span>, <span class="ruby-value str">&quot;to&quot;</span>)
50:     <span class="ruby-keyword kw">end</span>
51: 
52:     <span class="ruby-identifier">cc_users</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">user</span><span class="ruby-operator">|</span>
53:       <span class="ruby-identifier">add_recipient</span>(<span class="ruby-identifier">user</span>, <span class="ruby-value str">&quot;cc&quot;</span>)
54:     <span class="ruby-keyword kw">end</span>
55: 
56:     (<span class="ruby-identifier">to_users</span> <span class="ruby-operator">|</span> <span class="ruby-identifier">cc_users</span>).<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">user</span><span class="ruby-operator">|</span>
57:       <span class="ruby-identifier">user</span>.<span class="ruby-identifier">message_rules</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">rule</span><span class="ruby-operator">|</span>
58:         <span class="ruby-identifier">rule</span>.<span class="ruby-identifier">execute_rule</span>(<span class="ruby-keyword kw">self</span>)
59:       <span class="ruby-keyword kw">end</span>
60:     <span class="ruby-keyword kw">end</span>
61:   <span class="ruby-keyword kw">end</span></pre>
					</div>
					
				</div>

				

				
			</div>

		
			<div id="set-reply-fields-method" class="method-detail ">
				<a name="method-i-set_reply_fields"></a>

				<div class="method-heading">
				
					<span class="method-name">set_reply_fields</span><span
						class="method-args">()</span>
					<span class="method-click-advice">click to toggle source</span>
				
				</div>

				<div class="method-description">
					
					<h3>返信用の本文情報などを設定する</h3>
<p>
TODO: 引用符やらタイトルの返信ヘッダやら、設定ファイルからとれるようにすること
</p>
					

					
					<div class="method-source-code"
						id="set-reply-fields-source">
<pre>
    <span class="ruby-comment cmt"># File app/models/message.rb, line 84</span>
84:   <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">set_reply_fields</span>
85:     <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">subject</span> = <span class="ruby-node">&quot;Re: #{self.subject}&quot;</span>
86:     <span class="ruby-identifier">org_body</span> = <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">body</span>
87:     <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">body</span> = <span class="ruby-value str">&quot;&quot;</span>
88:     <span class="ruby-identifier">org_body</span>.<span class="ruby-identifier">each_line</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">line</span><span class="ruby-operator">|</span>
89:       <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">body</span> <span class="ruby-operator">+=</span> <span class="ruby-value str">&quot;&gt; &quot;</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">line</span>
90:     <span class="ruby-keyword kw">end</span>
91:     <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">body</span> = <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">body</span>.<span class="ruby-identifier">chomp</span> <span class="ruby-operator">+</span> <span class="ruby-value str">&quot;\n\n&quot;</span>
92:   <span class="ruby-keyword kw">end</span></pre>
					</div>
					
				</div>

				

				
			</div>

		
			<div id="to-addrs-method" class="method-detail ">
				<a name="method-i-to_addrs"></a>

				<div class="method-heading">
				
					<span class="method-name">to_addrs</span><span
						class="method-args">()</span>
					<span class="method-click-advice">click to toggle source</span>
				
				</div>

				<div class="method-description">
					
					<h3>メッセージに設定されている宛先をカンマ区切りの文字列として取得する</h3>
					

					
					<div class="method-source-code"
						id="to-addrs-source">
<pre>
    <span class="ruby-comment cmt"># File app/models/message.rb, line 64</span>
64:   <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">to_addrs</span>
65:     <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">message_recipients</span>.<span class="ruby-identifier">where</span>(<span class="ruby-value">:recipient_type</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-value str">&quot;to&quot;</span>).<span class="ruby-identifier">collect</span>{<span class="ruby-operator">|</span><span class="ruby-identifier">mr</span><span class="ruby-operator">|</span> <span class="ruby-identifier">mr</span>.<span class="ruby-identifier">user</span>.<span class="ruby-identifier">login</span>}.<span class="ruby-identifier">join</span>(<span class="ruby-value str">&quot;, &quot;</span>)
66:   <span class="ruby-keyword kw">end</span></pre>
					</div>
					
				</div>

				

				
			</div>

		
		</div>
	
		<div id="private-instance-method-details" class="method-section section">
			<h3 class="section-header">Private Instance Methods</h3>

		
			<div id="add-recipient-method" class="method-detail ">
				<a name="method-i-add_recipient"></a>

				<div class="method-heading">
				
					<span class="method-name">add_recipient</span><span
						class="method-args">(user, type)</span>
					<span class="method-click-advice">click to toggle source</span>
				
				</div>

				<div class="method-description">
					
					<h3>第一引数で指定されたユーザーのログイン名を第二引数で指定する宛先種別</h3>
<p>
（To: もしくは Cc:）で宛先リストに追加する
</p>
					

					
					<div class="method-source-code"
						id="add-recipient-source">
<pre>
     <span class="ruby-comment cmt"># File app/models/message.rb, line 127</span>
127:   <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">add_recipient</span>(<span class="ruby-identifier">user</span>, <span class="ruby-identifier">type</span>)
128:     <span class="ruby-identifier">recipient</span> = <span class="ruby-constant">MessageRecipient</span>.<span class="ruby-identifier">new</span>(<span class="ruby-value">:recipient_type</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">type</span>)
129:     <span class="ruby-identifier">recipient</span>.<span class="ruby-identifier">user</span> = <span class="ruby-identifier">user</span>
130:     <span class="ruby-identifier">recipient</span>.<span class="ruby-identifier">message</span> = <span class="ruby-keyword kw">self</span>
131:     <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">recipient</span>.<span class="ruby-identifier">save</span>
132:       <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">true</span>
133:     <span class="ruby-keyword kw">else</span>
134:       <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">false</span>
135:     <span class="ruby-keyword kw">end</span>
136:   <span class="ruby-keyword kw">end</span></pre>
					</div>
					
				</div>

				

				
			</div>

		
			<div id="check-recipient-list-method" class="method-detail ">
				<a name="method-i-check_recipient_list"></a>

				<div class="method-heading">
				
					<span class="method-name">check_recipient_list</span><span
						class="method-args">(list)</span>
					<span class="method-click-advice">click to toggle source</span>
				
				</div>

				<div class="method-description">
					
					<h3>引数で指定された文字列を分解し、ユーザーオブジェクトの配列にして</h3>
<p>
返す。ただし、1つでも非実在のユーザー名があった場合はfalseを返す
</p>
					

					
					<div class="method-source-code"
						id="check-recipient-list-source">
<pre>
     <span class="ruby-comment cmt"># File app/models/message.rb, line 112</span>
112:   <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">check_recipient_list</span>(<span class="ruby-identifier">list</span>)
113:     <span class="ruby-identifier">users</span> = []
114:     <span class="ruby-identifier">list</span>.<span class="ruby-identifier">split</span>(<span class="ruby-regexp re">/\s*,\s*/</span>).<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">name</span><span class="ruby-operator">|</span>
115:       <span class="ruby-identifier">user</span> = <span class="ruby-constant">User</span>.<span class="ruby-identifier">where</span>(<span class="ruby-value">:login</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">name</span>).<span class="ruby-identifier">first</span>
116:       <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">user</span>
117:         <span class="ruby-identifier">users</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-identifier">user</span>
118:       <span class="ruby-keyword kw">else</span>
119:         <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">false</span>
120:       <span class="ruby-keyword kw">end</span>
121:     <span class="ruby-keyword kw">end</span>
122:     <span class="ruby-keyword kw">return</span> <span class="ruby-identifier">users</span>
123:   <span class="ruby-keyword kw">end</span></pre>
					</div>
					
				</div>

				

				
			</div>

		
		</div>
	

	</div>


	<div id="rdoc-debugging-section-dump" class="debugging-section">
	
		<p>Disabled; run with --debug to generate this.</p>
	
	</div>

	<div id="validator-badges">
		<p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
		<p><small>Generated with the <a href="http://deveiate.org/projects/Darkfish-Rdoc/">Darkfish
			Rdoc Generator</a> 1.1.6</small>.</p>
	</div>

</body>
</html>

